# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: Jonathan Liu <net147@gmail.com>

_realname=opus-tools
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2
pkgrel=1
pkgdesc="Collection of tools for Opus audio codec (mingw-w64)"
arch=('any')
url="https://www.opus-codec.org/"
license=("BSD")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-flac"
         "${MINGW_PACKAGE_PREFIX}-libogg"
         "${MINGW_PACKAGE_PREFIX}-opus"
         "${MINGW_PACKAGE_PREFIX}-opusfile"
         "${MINGW_PACKAGE_PREFIX}-libopusenc")
options=('strip' 'staticlibs')
source=(https://downloads.xiph.org/releases/opus/${_realname}-${pkgver}.tar.gz)
sha256sums=('b4e56cb00d3e509acfba9a9b627ffd8273b876b4e2408642259f6da28fa0ff86')

build() {
  [[ -d "build-${MINGW_CHOST}" ]] && rm -rf "build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
